package org.jeecg.config;

import org.jeecg.filter.WebsocketFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: WebSocketConfig
 * @author: jeecg-boot
 */
@Configuration
public class WebSocketConfig {
    @Bean
    public WebsocketFilter websocketFilter(){
        return new WebsocketFilter();
    }

    @Bean
    public FilterRegistrationBean getFilterRegistrationBean(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(websocketFilter());

        //过滤所有路径
        bean.addUrlPatterns("/user/*","/history/*","/goods/*","/fans/*","/collect/*","/care/*");

        //TODO 临时注释掉，测试下线上socket总断的问题
//        bean.addUrlPatterns("/login/*");
        return bean;
    }

}
